package cn.jnetty.ioc.configruation;

import cn.jnetty.api.exception.JnettyIocException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;
import java.util.Iterator;
import java.util.Properties;

/**
 * @author 猪哥亮
 * @email 1030681978@qq.com
 * @date 2020/4/3 16:28
 * 描述：
 */
public class PropertiesConfiguration {
    private final Logger log = LoggerFactory.getLogger(PropertiesConfiguration.class);
    private Properties properties = new Properties();
    public void loading(String file){
        try {
            InputStream inputStream = this.getClass().getResourceAsStream("/" + file);
            if(inputStream == null){
                return;
            }
            Properties temp = new Properties();
            temp.load(inputStream);
            properties.putAll(temp);
            log.debug("解析的properties文件注解字段=======" + properties);
        } catch (Exception e) {
            throw new JnettyIocException("加载配置文件失败，找不到{0}这个文件",e,file);
        }
    }
    public String getValue(String key){
        return properties.getProperty(key);
    }
}
